<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>提取img标签</title>
</head>
<body>
	<textarea name="" id="textarea" cols="30" rows="10"></textarea>
	<button id="btn">提取img标签</button>
	<h1 id="hh"></h1>
	<script>
		var reg = /<img.*?src=[\'|\"](.*?(?:[\.gif|\.jpg|\.png]))[\'|\"].*?[\/]?>/ig;
		var textarea=document.querySelector("#textarea");
		var btn=document.querySelector('#btn');
		var h1=document.getElementById('hh');
		btn.onclick=function(){
			var str=textarea.value;
			var arr=str.match(reg);
			var newStr="";
			for (var i = 0; i < arr.length; i++) {
				console.log(arr[i])
			}
		}
	</script>
</body>
</html>